package com.srzk.youthleagueback.mapper;

import com.srzk.youthleagueback.pojo.Meeting;
import com.srzk.youthleagueback.pojo.ThematicEducation;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface ThematicEducationMapper {

    @InsertProvider(value = ThematicEducationProvider.class,method = "insertThematicEducation")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    int insert(ThematicEducation record);

    @Select("SELECT * FROM thematic_education WHERE id = #{id} user = #{user} AND year = #{year}")
    ThematicEducation selectByPrimaryKey(@Param("id") Long id,@Param("user")String user,@Param("year")String year);

    @Select("SELECT * FROM thematic_education WHERE user = #{user} AND year = #{year}")
    List<ThematicEducation> selectByPrimaryKeyList(@Param("user")String user,@Param("year")String year);

    @Select("SELECT * FROM thematic_education WHERE year = #{year}")
    List<ThematicEducation> selectByGrade(@Param("year")String year);

    @Select("SELECT * FROM thematic_education WHERE user = #{user}")
    List<ThematicEducation> selectAll(@Param("user")String user);

    @UpdateProvider(value = ThematicEducationProvider.class,method = "updateThematicEducation")
    int updateByPrimaryKey(ThematicEducation record);

    @Delete("DELETE FROM thematic_education WHERE user = #{user} AND year = #{year} AND id = #{id}")
    int deleteByUserAndYearAndTypeAndId(@Param("user")String user,@Param("year")String year,@Param("id")Long id);
}